package admin

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"zhuandan/data_source"
	"zhuandan/models"
)

func Tuiguangxyinfo(ctx *gin.Context) {
	var users models.Tuiguang
	data_source.Db.Where("id = 2").First(&users)
	ctx.JSON(http.StatusOK, gin.H{
		"code":    0,
		"error":   0,
		"success": 200,
		"data":    users,
		"msg":     "ok",
	})
	return
}
func Tuiguanginfo(ctx *gin.Context) {

	var users models.Tuiguang
	data_source.Db.Where("id = 1").First(&users)
	ctx.JSON(http.StatusOK, gin.H{
		"code":    0,
		"error":   0,
		"success": 200,
		"data":    users,
		"msg":     "ok",
	})
	return

}

type TuiguangBody struct {
	Bfb     int64  `json:"bfb" gorm:"bfb"`
	Content string `json:"content" gorm:"content"`
}

func Tuiguangupdate(ctx *gin.Context) {
	request := TuiguangBody{}
	ctx.ShouldBind(&request)
	bfb := request.Bfb
	content := request.Content
	tg := models.Tuiguang{
		Bfb:     bfb,
		Content: content,
	}
	data_source.Db.Where("id = 1").Updates(&tg)
	ctx.JSON(http.StatusOK, gin.H{
		"code":    0,
		"error":   0,
		"success": 200,
		"data":    "ok",
		"msg":     "ok",
	})
	return

}
func Tuiguangxsupdate(ctx *gin.Context) {
	request := TuiguangBody{}
	ctx.ShouldBind(&request)
	bfb := request.Bfb
	//content := request.Content
	tg := models.Tuiguang{
		Bfb: bfb,
	}
	data_source.Db.Where("id = 2").Updates(&tg)
	ctx.JSON(http.StatusOK, gin.H{
		"code":    0,
		"error":   0,
		"success": 200,
		"data":    "ok",
		"msg":     "ok",
	})
	return

}
